-
Notifications
You must be signed in to change notification settings - Fork 724
Comment parser #11252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Comment parser #11252
Conversation
This token is not needed, we will later use the position information to pad each token.
... which is not handling at all for the time being
|
Thank you Bodigrim and Jappie for your kind words! That means a lot to me, I'm glad to be on the right track. I have started (and completed) to rewrite my PR using Andrea's approach.
Good to know. Currently the top level parser drops the comments consumed if there are no fields to attach them to. Let me know what you think about the change :) |
This fixes builds for old GHC
|
Here are the benchmark results. The baseline has been rerun because I did these ones on a VPS machine, and they are not comparable to the last ones I ran on my machine. # baseline
leana@Ubuntu-2404-noble-amd64-base:~/cabal$ hyperfine './validate.sh --partial-hackage-tests'
Benchmark 1: ./validate.sh --partial-hackage-tests
Time (mean ± σ): 253.353 s ± 9.520 s [User: 196.642 s, System: 60.881 s]
Range (min … max): 241.649 s … 271.207 s 10 runs
# this PR
leana@Ubuntu-2404-noble-amd64-base:~/cabal$ hyperfine --setup "./validate.sh --partial-hackage-tests" "./validate.sh --partial-hackage-tests"
Benchmark 1: ./validate.sh --partial-hackage-tests
Time (mean ± σ): 253.163 s ± 7.451 s [User: 196.432 s, System: 58.507 s]
Range (min … max): 239.373 s … 266.656 s 10 runs |
In my prototype I have replaced Where the extra annotation is for anything coming after the last field.
In addition to @Bodigrim's
I am available to discuss and support her effort. @leana8959 I'll reach out privately.
I warmly second this! |
|
@leana8959, @andreabedini: how is the private communication going? We are interested too! Could we help somehow? |
|
for clarity: These parser changes are ready for review as far as leana and me are concerned, meanwhile we've moved over to import stanza retention in GenericPackageDescription (they currently get merged into the stanza's). This is an independent change of the parser changes here. After that we can start on exact print propper. |
Please don't. A lot of code wants an elaborated (= stripped down of syntactic convenience) representation of package description, and GPD serves that now. Your parsing changes leak down the pipeline where they shouldn't. E.g. things like solver works with GPD, and it really shouldn't care about whether import stanzas were used to declare a package or not. |
|
This PR isn't about that, |
|
This PR does add , exactComments :: ExactComments Positionfield to GPD. I don't see a point of having comments in GPD. (As noted in tests, it "breaks" equality) |
|
@phadej Indeed, I have added a newtype around |
|
I understand, the authors would like to get reviews for this PR. If this is so, please, squash the commit history. For the size of PR: a good part of the changes are test-suite changes, it seems. I don't think they have to be extracted into separate PR or even separate commits (because having commits that don't pass CI individually may be cumbersome in the future, for git-bisecting and alike). |
|
@mpickering can you take a high-level look at the design in this PR and tell us your opinion? The gist of it is: and then many parsing utilities that used to return -parseGenericPackageDescription'
+parseAnnotatedGenericPackageDescription'
:: Maybe CabalSpecVersion
-> [LexWarning]
-> Maybe Int
- -> [Field Position]
- -> ParseResult src GenericPackageDescription
-parseGenericPackageDescription' scannedVer lexWarnings utf8WarnPos fs = do
+ -> [Field (WithComments Position)]
+ -> ParseResult src AnnotatedGenericPackageDescription
+parseAnnotatedGenericPackageDescription' scannedVer lexWarnings utf8WarnPos fs = do |
|
One particular thing that bothers me is that clients will have to call Any thoughts? Meta-comment: I looked through the tech proposal again, and there doesn't appear to be a technical description of a solution for this particular comments issue. It is totally fine, because the proposal would turn into a foliant at that level of detail. Neveretheless, I wish that, before doing all the technical work in this PR, the authors had discussed the actual technical solution for the particular issue (like preserving comments; others are listed in the tech proposal) on the Cabal bug tracker (here). |
@ulysses4ever Are there some rule of thumb to squash my commits? I already went through the history once this morning and split out all changes that touch the testsuite into one commit. |
This is the first part of the exact print parser. In this PR I changed the lexer so instead of dropping the comments it emits them to the parser which is further stored in
GenericPackageDescription.Please let me know your thoughts!
Checklist below:
This PR modifies behaviour or interface
Include the following checklist in your PR:
significance: significantin the changelog file.